GBML manual / Paths

path_start

Starts this instance following a path. Give a speed to go at that speed all the way, or leave the speed out to go at the speed of each line, as set in the Paths tab.

Syntax

path_start(p, speed, end_action, relative)

Arguments

NameType
ppath
speedreal
end_actionpath_end_action
relativebool

Returns

Nothing.

Description

Starts this instance following a path. Give a speed to go at that speed all the way round, or leave the speed out to go at the speed of each line, as set in the Paths tab (see below). See Rooms's own "Paths, briefly" section for what a path is and how its four end actions behave.

Jumps the instance onto the path's own position-0 point at once - this frame, not eased in. Following happens in the engine's own motion phase and does NOT collide with anything; a patrol that must respect walls combines path_x_at/path_y_at with move_slide instead of following the path directly. relative chooses whether the path is followed relative to wherever this instance started, rather than at the path's own absolute drawn position - what makes one patrol path reusable by several instances, each patrolling the same shape around their own starting point instead of all converging on the path's literal coordinates.

A speed for each line

A line is the stretch of a path between two neighboring nodes, and each line can have a speed of its own: in the Paths tab, click the line and choose Set line speed (a rectangle can have four different speeds). To follow those speeds, leave the second argument empty, as in path_start(path_doc_patrol, , PATH_LOOP, false). The instance then goes at the speed of the line it is on, and path_speed always shows that speed. A line with no speed of its own goes at the path's own speed (Default speed in the Paths tab). A speed written in the call, as in path_start(path_doc_patrol, 1, PATH_LOOP, false), is used for every line and wins over the lines. Only the speed can be left out, and only in path_start; every other argument must be written.

Example

path_start(path_doc_patrol, 1, PATH_LOOP, false);

Starts the walker patrolling path_doc_patrol at 1 pixel a frame, at the path's own absolute drawn position (relative is false), looping back to the start every time it reaches the end.

On the GBA

Jumps the instance onto the path’s own pos-0 point at once (this frame, not eased in). Following happens in the motion phase and does NOT collide - a patrol that must respect walls uses move_slide() toward path_x_at()/path_y_at() instead. Each line of a path (the stretch between two neighboring nodes) can have a speed of its own: click the line in the Paths tab and pick Set line speed. To follow those speeds, leave the second argument empty: path_start(patrol, , PATH_LOOP, true). The instance then goes at the speed of the line it is on, and path_speed shows that speed. A line without a speed of its own goes at the path’s speed (the Default speed box in the Paths tab). A speed written in the call, as in path_start(patrol, 2, PATH_LOOP, true), goes for every line and wins over the lines. Only the speed can be left out, and only in path_start.

See also: path_stoppath_end_doRooms